package com.eastfair.home.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 监督项管理问卷
 * </p>
 *
 * @author linan
 * @date 2022-12-10
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "SupervisionItemQuestionQuestionTypeEnum", description = "问题类型 #{ESSAY_QUESTION:问答题;SINGLE_CHOICE:单选题;MULTIPLE_CHOICE:多选题-枚举")
public enum SupervisionItemQuestionQuestionTypeEnum implements BaseEnum {

    /**
     * ESSAY_QUESTION="问答题"
     */
    ESSAY_QUESTION("问答题"),
    /**
     * SINGLE_CHOICE="单选题"
     */
    SINGLE_CHOICE("单选题"),
    /**
     * MULTIPLE_CHOICE="多选题"
     */
    MULTIPLE_CHOICE("多选题"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static SupervisionItemQuestionQuestionTypeEnum match(String val, SupervisionItemQuestionQuestionTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static SupervisionItemQuestionQuestionTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(SupervisionItemQuestionQuestionTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "ESSAY_QUESTION,SINGLE_CHOICE,MULTIPLE_CHOICE", example = "ESSAY_QUESTION")
    public String getCode() {
        return this.name();
    }

}
